<?php

class Default_Model_Role extends Zend_Db_Table_Abstract
{
    protected $_name = 'role';
    
    public function getDataByUserId($userId){
        $query = $this->select()
                        ->setIntegrityCheck(false)
                        ->from(array('r'=>$this->_name), array('r.roleId', 'r.roleName','r.homepage','r.gameId','r.resourceId'))
                        ->join(array('ur'=>'user_role'),'r.roleId = ur.roleId', array('ur.userId'))
                        ->where('ur.userId = ?',(int)$userId);
                                        
    	return $this->fetchAll($query);
    }
    public function getDataByUserIdGameId($userId, $gameId){
        $query = $this->select()
                        ->setIntegrityCheck(false)
                        ->from(array('r'=>$this->_name), array('r.roleId', 'r.roleName','r.homepage','r.gameId','r.resourceId','r.channelDisabled'))
                        ->join(array('ur'=>'user_role'), 'ur.roleId = r.roleId AND ur.userId = '.$userId, array())
                        ->where('r.gameId like ?',"%$gameId%");
                        
    	return $this->fetchAll($query);
    }
}

























